<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 原有数据：
        let str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
        let cites = [
            { py: 'beijing', name: '北京' },
            { py: 'alishan', name: '阿里山' },
            { py: 'beidaihe', name: '北戴河' },
            { py: 'shijiazhuang', name: '石家庄' },
            { py: 'shanxi', name: '山西' },
            { py: 'xuliya', name: '叙利亚' },
            { py: 'chengdu', name: '成都' },
            { py: 'meilijian', name: '美利坚' },
            { py: 'eluosi', name: '俄罗斯' },
            { py: 'aodaliya', name: '澳大利亚' },
            { py: 'jiangsu', name: '江苏' },
            { py: 'shanghai', name: 'shanghai' },
            { py: 'aomen', name: '澳门' },
            { py: 'xianggang', name: '香港' },
            { py: 'bingdao', name: '冰岛' },
            { py: 'fandigang', name: '梵蒂冈' },
            { py: 'jierjisisitan', name: '吉尔吉斯斯坦' },
            { py: 'jianada', name: '加拿大' }
        ]
        let arr = [];
        let obj1 = {};
        arr = str.split("");
        for (let i = 0; i < arr.length; i++) {
            obj1[arr[i]] = [];
            for (let j = 0; j < cites.length; j++) {
                if (arr[i] == cites[j].py[0].toUpperCase()) {
                    obj1[arr[i]].push(cites[j])
                }
            }
        }
        console.log(obj1);
        // 需要生成的数据：
        // {
        //     A: [{ py: 'alishan', name: '阿里山' }],
        //     B: [{ py: 'beijing', name: '北京' }, { py: 'beidaihe', name: '北戴河' }],
        //     c: [],
        // ...
        // }
        // 提示：
        // 1. 根据str 生成  obj = { A: [], B: [], C: []...Z: []}
        // 2. 根据cites 里py中的第一个字母，作为obj对象的属性名   

    </script>
</body>

</html>